#include <unordered_map>
#include <string>

using std::string;
using std::unordered_map;

class Solution {
public:
    bool canConstruct(string ransomNote, string magazine) {
        unordered_map<char, int> map;
        for (char c : ransomNote) {
            map[c]++;
        }
        for (char c : magazine) {
            map[c]--;
        }
        for (std::pair<char, int> p : map) {
            if (p.second > 0) {
                return false;
            }
        }
        return true;
    }
};